from typing import List


class Solution:
    def relativeSortArray(self, arr1: List[int], arr2: List[int]) -> List[int]:
        rank ={num:i for i,num in enumerate(arr2)}
        # def compare(x,y):
        #     rx =rank[x] if x in rank else len(arr2) +x
        #     ry = rank[y] if y in rank else len (arr2) +y
        #     return rx -ry
        arr1.sort(key=lambda x:rank[x] if x in rank else len(arr2)+x)
        return arr1
